<template>
  <el-dialog v-model="dialog.visible" title="邀请人员信息" width="70%" @close="handleCloseDialog">
    <BasePageTable :table-data="tableData" :table-columns-data="tableColumnsData" height="500">
      <template #avatar="{ row, index }">
        <el-image style="width: 100px; height: 100px" :src="row.avatar" />
      </template>
    </BasePageTable>
    <template v-if="canEdit" #footer>
      <div class="dialog-footer">
        <el-button type="primary" @click="handleSubmit">确 定</el-button>
        <el-button @click="handleCloseDialog">取 消</el-button>
      </div>
    </template>
  </el-dialog>
  <el-drawer v-model="drawer" title="I am the title" :before-close="handleClose">
    <span>Hi, there!</span>
  </el-drawer>
</template>
<script setup lang="ts">
import BasePageTable from "@/components/BasePageTable/index.vue";
// 定义 emit，用于通知外部关闭事件
const emit = defineEmits(["update:modelValue", "loadData"]);
const dialog = reactive({
  title: "",
  visible: false,
});
const drawer = ref(false);
const formRef = ref();
const tableData = ref([]);
const tableColumnsData = ref([
  { label: "用户昵称", align: "center", prop: "nickname" },
  { label: "分享码", align: "center", prop: "ownInviteCode" },
]);

async function handleSubmit() {
  handleCloseDialog();
}

// 关闭弹窗
function handleCloseDialog() {
  dialog.visible = false;
  emit("update:modelValue", false); // 关闭弹窗
}

async function showModal(val) {
  dialog.visible = true;
  tableData.value = val;
}

defineExpose({
  showModal,
});
</script>
<style style="scss" scoped>
:deep(.el-table .cell) {
  overflow: visible !important;
}
.custom-error-message {
  position: absolute;
  bottom: -20px;
  left: 0;
  color: red;
}
.form-container {
  /* //height: 600px; */
  overflow: auto;
}
.form {
  ::v-deep(.el-form-item) {
    margin-bottom: 0;
  }
}
</style>
